package com.youku.expression.ast;

import com.youku.exception.UndefineVariableException;
import com.youku.expression.Token;
import com.youku.expression.environment.Environment;

/**
 * 变量标识符
 * @author loda
 *
 */
public class IdentifierAst extends Ast {

	public IdentifierAst(Token token,Ast...asts) {
		super(token, asts);
	}

	@Override
	public Object eval(Environment environment) {
		Object value = environment.get(getTokenValue());
		if (value == null)
			throw new UndefineVariableException("无法识别" + getTokenValue());

		return value;
	}
}
